<template>
	<u-popup :show="show" :round="10" mode="bottom" @close="close" closeOnClickOverlay>
		<view class="popup-box">
			<slot></slot>

			<view v-if="showFooter" class="btn-box">
				<view v-if="showCancel" @click="onCancel" class="cancel-btn">
					{{cancelText}}
				</view>
				<view v-if="showConfirm" @click="onConfirm" class="confirm-btn">
					{{confirmText}}
				</view>
			</view>
			<view v-else class="btn-box">
				<view v-if="showConfirm" @click="onConfirm" class="confirm-btn">
					{{confirmText}}
				</view>
			</view>
		</view>
	</u-popup>
</template>

<script>
	export default {
		props: {
			show: Boolean,
			cancelText: {
				type: String,
				default: '取消'
			},
			confirmText: {
				type: String,
				default: '确定'
			},
			// 是否显示底部按钮
			showFooter: {
				type: Boolean,
				default: true
			},
			showConfirm: {
				type: Boolean,
				default: true
			},
			showCancel: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {}
		},
		methods: {
			onConfirm() {
				this.$emit("onConfirm")
			},
			onCancel() {
				this.$emit("onCancel")
			},
			close() {
				this.$emit("onClose")
			}
		}
	}
</script>

<style lang="scss" scoped>
	.popup-box {
		padding: 50rpx 30rpx;

		.btn-box {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 50rpx;
			font-size: 30rpx;

			>view {
				flex: 1;
				text-align: center;
			}

			>view:last-child {
				margin-right: 0;
			}

			.cancel-btn {
				height: 88rpx;
				margin-right: 20rpx;
				line-height: 88rpx;
				background-color: #f0f1f5;
				border-radius: 8rpx;
			}

			.confirm-btn {
				height: 88rpx;
				line-height: 88rpx;
				background-color: #166ffc;
				border-radius: 8rpx;
				color: #fff;
			}
		}
	}
</style>